<template>
	<view>
		<u-navbar ref="navbar" title="实名认证" leftIcon="arrow-left" autoBack placeholder=""></u-navbar>

		<!-- <view class="box"> -->
		<!-- <view class="color-3 font-28 mb-30">{{type==0?'请上传你的身份证照片':'请拍摄并上传贵公司的营业执照'}}</view> -->
		<!-- <view class="flex-sb" v-if="type==0">
				<view>
					<view class="upload_box relative" @tap="$u.throttle(upload_card('a'), 500)">
					<view class="upload_box relative" @tap="upload_cardFn('a')">
							<u-image :src="card_a ? card_a : '../../static/image/real_name_just.png'" width="324rpx"
							height="280rpx">
							<template v-slot:loading>
								<text class="font-28">加载中...</text>
							</template>
						</u-image>
						<u-image
							:src="card_a ? card_a : 'http://image.xjsdd.com/upload/20220916/ed59f067e58454f04ca01615f3981e95.png'"
							width="324rpx" height="280rpx">
							<template v-slot:loading>
								<text class="font-28">加载中...</text>
							</template>
						</u-image>
						<view v-show="positive" class="upload_box_text">拍摄正面</view>
					</view>
				</view>
				<view>
					<view class="upload_box relative" @tap="$u.throttle(upload_card('b'), 500)">
					<view class="upload_box relative" @tap="upload_cardFn('b')">
						<u-image :src="card_b ? card_b : '../../static/image/real_name_back.png'" width="324rpx"
							height="280rpx">
							<template v-slot:loading>
								<text class="font-28">加载中...</text>
							</template>
						</u-image>
						<u-image
							:src="card_b ? card_b : 'http://image.xjsdd.com/upload/20220916/922cce8527cb9133584c6e605994e2d0.png'"
							width="324rpx" height="280rpx">
							<template v-slot:loading>
								<text class="font-28">加载中...</text>
							</template>
						</u-image>
						<view v-show="back" class="upload_box_text">拍摄反面</view>
					</view>
				</view>
			</view> -->

		<!-- 	<view class="flex-c" v-else>
				<view>
					<view class="upload_box relative" @tap="$u.throttle(upload_card('a'), 500)">
					<view class="upload_box relative" @tap="upload_cardFn('c')">
							<u-image :src="card_a ? card_a : '../../static/image/real_name_just.png'" width="324rpx"
							height="280rpx">
							<template v-slot:loading>
								<text class="font-28">加载中...</text>
							</template>
						</u-image>
						<u-image
							:src="license_img ? license_img : 'http://image.xjsdd.com/upload/20231117/0d82fe5ca378a5b65d723f7c0cdea395.png'"
							width="324rpx" height="280rpx">
							<template v-slot:loading>
								<text class="font-28">加载中...</text>
							</template>
						</u-image>
						<view v-show="license_tip_show" class="upload_box_text">拍摄正面</view>
					</view>
				</view>
			</view> -->
		<!-- </view> -->

		<view class="form_box_item mt-20">
			<view class="form_box_label">真实姓名：</view>
			<u-input disabledColor="#fff" v-model="psnName" :maxlength="5" placeholder="请填写真实姓名" fontSize="28rpx"
				border="bottom" class="form_box_input">
			</u-input>
		</view>
		<view class="form_box_item">
			<view class="form_box_label">身份证号：</view>
			<u-input disabledColor="#fff" v-model="psnIDCardNum" :maxlength="18" placeholder="请输入身份证号" fontSize="28rpx"
				border="bottom" class="form_box_input">
			</u-input>
		</view>

		<!-- <view class="form_box_item_radio" v-if="type==0">
			<view class="form_box_label">性别：</view>
			<view class="flex-item-c">
				<u-radio-group v-model="message.sex" placement="row" size="30rpx" :disabled="overlay">
					<u-radio :customStyle="{marginRight: '50rpx'}" label="男" name="1" labelSize="28rpx"
						labenColor="#333" activeColor="#2ABDA7" inactiveColor="#2ABDA7"></u-radio>
					<u-radio :customStyle="{marginRight: '50rpx'}" label="女" name="2" labelSize="28rpx"
						labenColor="#333" activeColor="#2ABDA7" inactiveColor="#2ABDA7"></u-radio>
				</u-radio-group>
			</view>
		</view> -->

		<!-- <view class="form_box_item mt-20" v-if="type==1">
			<view class="form_box_label">企业名称：</view>
			<u-input :disabled="overlay" disabledColor="#fff" v-model="companyInfo.name" :maxlength="18"
				placeholder="请输入企业名称" fontSize="28rpx" border="bottom" class="form_box_input">
			</u-input>
		</view>
		<view class="form_box_item" v-if="type==1">
			<view class="form_box_label">企业地址：</view>
			<u-input :disabled="overlay" disabledColor="#fff" v-model="companyInfo.zj_address" :maxlength="18"
				placeholder="请输入企业地址" fontSize="28rpx" border="bottom" class="form_box_input">
			</u-input>
		</view>
		<view class="form_box_item pb-20" v-if="type==1">
			<view class="form_box_label">执照编号：</view>
			<u-input :disabled="overlay" disabledColor="#fff" v-model="companyInfo.idcard" :maxlength="18"
				placeholder="请输入执照编号" fontSize="28rpx" border="bottom" class="form_box_input">
			</u-input>
		</view> -->

		<!-- <view class="box font-26" v-if="type==0">
			<view>拍摄身份证要求：</view>
			<view>大陆公民持有的本人有效二代身份证；</view>
			<view>
				<text>拍摄时确保身份证</text>
				<text>边框完整，字体清晰，亮度均匀；</text>
			</view>
			<view class="flex-sb" style="align-items: flex-end;">
				<view>
				
					<u-image src="http://image.xjsdd.com/upload/20220916/ff46350340e134ffe68e394a7b22ef78.png"
						width="160rpx" height="110rpx"></u-image>
					<view class="rule_text">标准</view>
				</view>
				<view>
				
					<u-image src="http://image.xjsdd.com/upload/20220916/ed506da9cd7e9b269b47121848da7b94.png"
						width="160rpx" height="136rpx"></u-image>
					<view class="rule_text">边框缺失</view>
				</view>
				<view>
				
					<u-image src="http://image.xjsdd.com/upload/20220916/3098acc3a24edee51e326bebcf22fd5e.png"
						width="160rpx" height="116rpx"></u-image>
					<view class="rule_text">对焦模糊</view>
				</view>
				<view>
				
					<u-image src="http://image.xjsdd.com/upload/20220916/eecec9dee0686e9fc53fc15f1dabfe73.png"
						width="160rpx" height="116rpx"></u-image>
					<view class="rule_text">闪光强烈</view>
				</view>
			</view>
		</view> -->
		<!-- 	<view class="box font-26" v-else>
			<view>拍摄营业执照要求：</view>
			<view class="mt-20" style="color: #E73146;">1.请确保您是具有法人资格的商户，您需提供可证明您依法设立，依法经营，开展社会活动的执照证件等(如营业执照副本)</view>
			<view class="mt-20 mb-20" style="color: #E73146;">2.证件有效期在3个月内的商户，请找工商部门更新资料后再行提交</view>
			<view>
				<text>拍摄时确保营业执照</text>
				<text style="color: #E73146;">边框完整，字体清晰，亮度均匀；</text>
			</view>
			<view class="flex-sb" style="align-items: flex-end;">
				<view>
					
					<u-image src="http://image.xjsdd.com/upload/20231117/6c8a087757c19e737c5a6ca49442841d.png"
						width="160rpx" height="110rpx"></u-image>
					<view class="rule_text">标准</view>
				</view>
				<view>
				
					<u-image src="http://image.xjsdd.com/upload/20231117/7f983ece8265468a082884cb25020817.png"
						width="160rpx" height="116rpx"></u-image>
					<view class="rule_text">边框缺失</view>
				</view>
				<view>
					
					<u-image src="http://image.xjsdd.com/upload/20231117/99e38e0ea0e9f4513016e2bfb6f6d084.png"
						width="160rpx" height="116rpx"></u-image>
					<view class="rule_text">对焦模糊</view>
				</view>
				<view>
					
					<u-image src="http://image.xjsdd.com/upload/20231117/36c7586708d771918a7f389188881454.png"
						width="160rpx" height="116rpx"></u-image>
					<view class="rule_text">闪光强烈</view>
				</view>
			</view>
		</view> -->


		<view class="button submitBtn" @tap="$u.throttle(submit, 1000)">提交资料</view>
		<u-gap height="30rpx"></u-gap>
		<u-toast ref="uToast"></u-toast>
		<!-- <Upload ref="myUpload" v-show="false"></Upload> -->
	</view>
</template>

<script>
	// import Upload from '../components/upload'
	import {
		realName
	} from '@/config/api.js'
	export default {
		data() {
			return {
				// message: {
				// 	name: '',
				// 	idcardinfo: '',
				// 	sex: '',
				// },
				// overlay: false, //是否覆盖
				// positive: true, //是否展示正面拍摄提示
				// back: true, //是否展示反面拍摄提示
				// card_a: '',
				// card_b: '',
				// type: 0, //0个人 1企业
				// license_img: '', //营业执照照片
				// license_tip_show: true, //是否展示营业执照拍摄提示
				// companyInfo: {} //公司信息
				psnName: '',
				psnIDCardNum: ''
			}
		},
		onLoad(op) {
			this.type = op.type
		},
		onShow() {

		},
		components: {
			// Upload
		},
		methods: {
			async submit() {
				if (!this.psnName) {
					return uni.showToast({
						icon: 'none',
						title: '请输入真实姓名'
					})

				}
				if (!uni.$u.test.idCard(this.psnIDCardNum)) {
					return uni.showToast({
						icon: 'none',
						title: '请输入正确身份证号'
					})
				}

				uni.showLoading({
					mask: true,
					title: '提交中'
				})
				const res = await realName({
					type: 'h5',
					psnName: this.psnName,
					psnIDCardNum: this.psnIDCardNum
				})
				uni.hideLoading()
				if (res.code == 1) {
					uni.showToast({
						icon: 'none',
						title: res.msg,
						complete: () => {
							uni.navigateTo({
								url: './realNameWbeView?src=' + encodeURIComponent(res.data
									.authUrl)
							})
						}
					})
				} else {
					uni.showToast({
						icon: 'none',
						title: res.msg
					})
				}
			},
		}
	}
</script>

<style>
	page {
		background: #F5F6F8;
	}
</style>

<style lang="scss" scoped>
	.form_box_item {
		display: flex;
		justify-content: space-between;
		align-content: center;
		background: #fff;
		padding: 30rpx 30rpx 0;
	}

	.form_box_item_radio {
		display: flex;
		align-content: center;
		background: #fff;
		padding: 30rpx 30rpx 0;
	}

	.form_box_label {
		font-size: 28rpx;
		color: #333;
		position: relative;
		margin-left: 20rpx;
		min-width: 140rpx;
		line-height: 80rpx;
	}

	.box {
		margin-top: 20rpx;
		padding: 28rpx 28rpx;
		background: #fff;

		.upload_box {
			border-radius: 0 0 10rpx 10rpx;
			overflow: hidden;
		}

		.upload_box_text {
			position: absolute;
			bottom: 0;
			left: 0;
			background: #ff820d;
			color: #fff;
			width: 100%;
			padding: 14rpx 0 20rpx;
			text-align: center;
			font-size: 28rpx;
		}

		.rule_text {
			text-align: center;
			font-size: 26rpx;
			margin-top: 10rpx;
			color: #919191;
		}
	}

	.submitBtn {
		margin: 60rpx 30rpx 0;
		padding: 30rpx 0;
		background: #ff820d;
		border-radius: 10rpx;
		font-size: 28rpx;
		font-weight: bold;
		color: #FFFFFF;
		text-align: center;
	}

	.bg {
		position: fixed;
		width: 100%;
		height: 100vh;
		left: 0;
		top: 300rpx;
		z-index: 999999;
		background: rgba(0, 0, 0, 0);
	}
</style>